package com.threads;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 *
 * 我想做一个跟着线程休眠时间的一个简易小程序
 * @author 13699
 */
public class LocalDatetimeThread implements Runnable {

    public static void main(String[] args) {
        LocalDatetimeThread ldt=new LocalDatetimeThread();
        ldt.run();

    }

    @Override
    public void run() {
        try {
            while (true){
                LocalDateTime localDateTime=LocalDateTime.now();
                TimeUnit.MILLISECONDS.sleep(3000);
                System.out.println(localDateTime+"每3秒记录一次时间");
            }

        }catch (InterruptedException e){
            System.out.println("Interrupted");
        }
    }
}
